<?php
/*
	author:henson
	date:2011-12-11
	function:教程顶和踩 1小时内只允许同一个iP顶踩一次
*/
require_once('common.inc.php');
require_once(_INC_PATH.'database.php');
require_once(_INC_PATH.'fun.php');
include_once(_INC_PATH.'global.php' );

if(!strpos($_SERVER['HTTP_REFERER'], '87dianping.com'))die("illegal path");

$id = intval($_REQUEST['id']);
if($id > 0){
	$db = new database();
	if(isset($_REQUEST['type']) && $_REQUEST['type'] == "down"){
		$type = "down";
	}else{
		$type = "up";
	}
	$ip = getIp();
	$dtime = time() -  3600;
	$sql = "select * from tbl_pj where id='$id' and ip='$ip' and addTime>$dtime limit 1";
	if($db->loadResult($sql)){
		echo 'false';
		die;
	}else{
		$temprow = array();
		$temprow['id'] = $id;
		$temprow['type'] = $type;
		$temprow['ip'] = getIp();
		$temprow['addTime'] = time();
		$db->insert($temprow, 'tbl_pj');
		echo 'ok';
		die;
	}
	
}
die;
?>